
//旧方法
function Person1(name) {
  this.name = name;
}

//通过原型链添加方法
Person1.prototype.say = function () {
  console.log(this.name)
}
const p1 = new Person1();
p1.say()
//--------------------------------------
//新方法

class Person2 {
  //构造函数
  constructor(name) {
    this.name = name;
  }

  say() {
    console.log(this.name);
  }
}

const p2 = new Person2();
p2.say()